<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../js/vue.js"></script>
</head>
<body>
    <div id="app">
        <my-cly :width="width"></my-cly>
        <input type="text" v-model="width">

    </div>
    <template id="temp">
    <div :style="style" style="background-color: yellow;">组件内容宽度{{width}}px,背景颜色为黄色。</div>
    </template>


    <script type="text/javascript">
        Vue.component('my-cly',{
            props:['width'],
                template:'#temp',
                computed:{
                    style: function(){
                        return{
                            width:this.width +'px'
                        }
                    }
                }
        });

        var app = new Vue({
            el: '#app',
            data:{
                width:120
            }

        });
    </script>
</body>
</html>